
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <poll.h>
#include <signal.h>

static int fd;

/*
 * ./dac_test /dev/myspi
 *
 */
int main(int argc, char **argv)
{
	int fd;
	int buf[2];
	unsigned short dac_val = 0;
	if (argc != 3)
	{
		printf("Usage: %s <dev> <val>\n");
		return -1;
	}
	fd = open(argv[1],0_RDWR);
	if (fd < 0)
	{
		printf("can not open %s \n",argv[1]);
		return -1;
	}
	dac_val = strtoul(argv[2], NULL, 0);
	//while (1)
	{
		write(fd,&dac_val,2);
	}
	close(fd);
	
	return 0;
}


